//
//  SEGHLBNeihborhoodDetailViewModel.m
//  SEGViewModel
//
//  Created by 梁学彰 on 2020/11/18.
//

#import "SEGHLBNeihborhoodDetailViewModel.h"

@implementation SEGHLBNeihborhoodDetailViewModel
#pragma mark - life cycle


#pragma mark - init

#pragma mark - send request
- (RACSignal *)requestDetailInfoWithOperationType:(SEGNeighbourhoodOperationType)type objId:(NSString *)objId {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        WeakSelf;
        if (type == SEGNeighbourhoodOperationType_FowardPGC) { // 转发PGC
            [subscriber sendError:nil];
        } else if (type == SEGNeighbourhoodOperationType_Market) { // 集市
            [self.sHManager requestGetGoodsIdelBygoodsId:objId Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
                [subscriber sendNext:nil];
                if (isSuccessed) {
                    weakSelf.isMy = [ValueToString(weakSelf.sHManager.dataSourceGoodsIdel.userId) isEqualToString:kAccountUserID];
                    weakSelf.marketContent = [NSString stringWithFormat:@"%@，%@", weakSelf.sHManager.dataSourceGoodsIdel.title, weakSelf.sHManager.dataSourceGoodsIdel.exp];
                    weakSelf.userModel = [[SEGSharedCommonUserModel alloc] init];
                    weakSelf.userModel.userId = weakSelf.sHManager.dataSourceGoodsIdel.userId;
                    weakSelf.userModel.nickName = weakSelf.sHManager.dataSourceGoodsIdel.userName;
                    weakSelf.userModel.icon = weakSelf.sHManager.dataSourceGoodsIdel.userIcon;
                    weakSelf.userModel.isAuth = weakSelf.sHManager.dataSourceGoodsIdel.isAuth;
                    weakSelf.userModel.sex = weakSelf.sHManager.dataSourceGoodsIdel.sex;
                    // 刷新底部点赞 收藏数
                    [subscriber sendCompleted];
                } else {
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
            }];
        } else {
            [self.helpManager requestQuizDetailByQuizId:objId Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
                [subscriber sendNext:nil];
                if (isSuccessed) {
                    weakSelf.isMy = [weakSelf.helpManager.dataSourceQuizDetail.userId isEqualToString:kAccountUserID];
                    weakSelf.userModel = [[SEGSharedCommonUserModel alloc] init];
                    weakSelf.userModel.userId = weakSelf.helpManager.dataSourceQuizDetail.userId;
                    weakSelf.userModel.nickName = weakSelf.helpManager.dataSourceQuizDetail.userName;
                    weakSelf.userModel.icon = weakSelf.helpManager.dataSourceQuizDetail.ico;
                    weakSelf.userModel.isAuth = [weakSelf.helpManager.dataSourceQuizDetail.isAuth stringValue];
                    weakSelf.userModel.sex = [weakSelf.helpManager.dataSourceQuizDetail.sex stringValue];
                    // 刷新底部点赞 收藏数
                    [subscriber sendCompleted];
                    
                } else {
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
            }];
        }
        return nil;
    }];
    return signal;
}

- (RACSignal *)requestCommentsWithObjId:(NSString *)objId objType:(NSString *)objType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        [self.sharedNewManager requestQueryCommentsWithObjId:objId objType:objType pageNo:[NSString stringWithFormat:@"%ld",(unsigned long)self.pageNo] pageLimit:@"10" finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
            [subscriber sendNext:nil];
            if (isSuccessed) {
                [subscriber sendCompleted];
            }else {
                [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
            }
        }];
        
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)seg_commentForwardPGCWithNickName:(NSString *)nickName objId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType{
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        if(!self.sharedNewManager.fowardInfoModel.sharePicture || !self.userModel) {
            [subscriber sendError:nil];
            return nil;
        }
        
        [self.sharedNewManager requestSaveQuizAnswerByquizId:objId
                                                 answContent:self.commentContent
                                                     creator:nickName
                                                  byReviewId:nil
                                                byReviewNick:nil
                                              byReviewUserId:self.userModel.userId
                                               objSendUserId:self.userModel.userId
                                             objPicUrlForMsg:self.sharedNewManager.fowardInfoModel.sharePicture
                                              objTitleForMsg:self.sharedNewManager.fowardInfoModel.shareContent
                                                    objeType:self.sharedNewManager.fowardInfoModel.objType
                                                 parentObjId:objId
                                               parentObjType:SEGUserType_QUESTION
                                               operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                             sourceCommentId:nil
                                                    isParent:nil
                                                    Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
            if (isSuccessed) {
                [subscriber sendCompleted];
            }else {
                [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
            }
        }];
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)seg_commentMarketWithNickName:(NSString *)nickName objId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        if(!self.sHManager.dataSourceGoodsIdel) {
            [subscriber sendError:nil];
            return nil;
        }
        WeakSelf;
        [self.sharedNewManager requestCommentSaveByobjId:objId
                                                 objType:objType
                                          commentContent:self.commentContent
                                                 creator:kAccountNickName
                                              byReviewId:nil
                                            byReviewNick:nil
                                          byReviewUserId:self.sHManager.dataSourceGoodsIdel.userId
                                         objPicUrlForMsg:self.sHManager.dataSourceGoodsIdel.img1
                                          objTitleForMsg:self.sHManager.dataSourceGoodsIdel.title
                                             parentObjId:self.sHManager.dataSourceGoodsIdel.goodsId
                                           parentObjType:[objType integerValue]
                                           operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                         sourceCommentId:nil
                                                isParent:@"1"
                                                Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
            StrongSelf;
            if (!strongSelf) {
                [subscriber sendError:nil];
                return;
            }
            if (!isSuccessed) { //
                [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
            }
            [subscriber sendCompleted];
        }];
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)seg_commentHelpOrTopicWithNickName:(NSString *)nickName objId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        if(!self.helpManager.dataSourceQuizDetail) {
            [subscriber sendError:nil];
            return nil;
        }
        WeakSelf;
        [self.sharedNewManager requestSaveQuizAnswerByquizId:objId
                                                 answContent:self.commentContent
                                                     creator:nickName
                                                  byReviewId:nil
                                                byReviewNick:nil
                                              byReviewUserId:self.helpManager.dataSourceQuizDetail.userId
                                               objSendUserId:self.helpManager.dataSourceQuizDetail.userId
                                             objPicUrlForMsg:self.helpManager.dataSourceQuizDetail.quizPic
                                              objTitleForMsg:self.helpManager.dataSourceQuizDetail.quizContent1
                                                    objeType:self.helpManager.dataSourceQuizDetail.objType
                                                 parentObjId:objId
                                               parentObjType:operationType == SEGNeighbourhoodOperationType_Topic ? SEGUserType_ACTIVITY : SEGUserType_QUESTION
                                               operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                             sourceCommentId:nil
                                                    isParent:@"1"
                                                    Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
            StrongSelf;
            if (!strongSelf) {
                [subscriber sendError:nil];
                return;
            }
            if (!isSuccessed) { //
                [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
            }
            [subscriber sendCompleted];
        }];
        
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)seg_commentToChildCommentWithObjId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        if (self.sharedNewManager.commentsArray.count <= self.selectedIndexPath.row) {
            [subscriber sendError:nil];
            return nil;
        }
        WeakSelf;
        SEGSharedCommentModel *model = self.sharedNewManager.commentsArray[self.selectedIndexPath.row];
        if (self.selectChildIndex == -1) {//对子评论的主体回复
            [self.sharedNewManager requestSaveQuizAnswerByquizId:objId
                                                     answContent:self.commentContent
                                                         creator:kAccountNickName
                                                      byReviewId:model.comment.id
                                                    byReviewNick:model.user.nickName
                                                  byReviewUserId:model.user.userId
                                                   objSendUserId:kAccountUserID
                                                 objPicUrlForMsg:@""
                                                  objTitleForMsg:model.comment.content
                                                        objeType:model.comment.objType
                                                     parentObjId:objId
                                                   parentObjType:operationType == SEGNeighbourhoodOperationType_Topic ? SEGUserType_ACTIVITY : SEGUserType_QUESTION
                                                   operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                                 sourceCommentId:model.comment.id
                                                        isParent:@"2"
                                                        Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
                StrongSelf;
                if (!strongSelf) {
                    [subscriber sendError:nil];
                    return;
                }
                if (!isSuccessed) { //
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
                [subscriber sendCompleted];
            }];
        } else {
            SEGSharedCommentChildCommentModel*childModel = model.comment.childComment[self.selectChildIndex];
            [self.sharedNewManager requestSaveQuizAnswerByquizId:objId
                                                     answContent:self.commentContent
                                                         creator:kAccountNickName
                                                      byReviewId:childModel.comment.id
                                                    byReviewNick:childModel.user.nickName
                                                  byReviewUserId:childModel.user.userId
                                                   objSendUserId:kAccountUserID
                                                 objPicUrlForMsg:@""
                                                  objTitleForMsg:childModel.comment.content
                                                        objeType:model.comment.objType
                                                     parentObjId:objId
                                                   parentObjType:operationType == SEGNeighbourhoodOperationType_Topic ? SEGUserType_ACTIVITY : SEGUserType_QUESTION
                                                   operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                                 sourceCommentId:model.comment.id
                                                        isParent:@"2"
                                                        Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
                StrongSelf;
                if (!strongSelf) {
                    [subscriber sendError:nil];
                    return;
                }
                if (!isSuccessed) { //
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
                [subscriber sendCompleted];
            }];
        }
        
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)seg_commentMarketChildCommentWithNickName:(NSString *)nickName objId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        if (self.sharedNewManager.commentsArray.count <= self.selectedIndexPath.row) {
            [subscriber sendError:nil];
            return nil;
        }
        WeakSelf;
        SEGSharedCommentModel *model = self.sharedNewManager.commentsArray[self.selectedIndexPath.row];
        if (self.selectChildIndex == -1) {//对子评论的主体回复
            [self.sharedNewManager requestCommentSaveByobjId:objId
                                                     objType:objType
                                              commentContent:self.commentContent
                                                     creator:kAccountNickName
                                                  byReviewId:model.comment.id
                                                byReviewNick:model.user.nickName
                                              byReviewUserId:model.user.userId
                                             objPicUrlForMsg:nil
                                              objTitleForMsg:model.comment.content
                                                 parentObjId:objId
                                               parentObjType:[objType integerValue]
                                               operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                             sourceCommentId:model.comment.id
                                                    isParent:@"2"
                                                    Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                StrongSelf;
                if (!strongSelf) {
                    [subscriber sendError:nil];
                    return;
                }
                if (!isSuccessed) { //
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
                [subscriber sendCompleted];
            }];
        } else {
            SEGSharedCommentChildCommentModel*childModel = model.comment.childComment[self.selectChildIndex];
            [self.sharedNewManager requestCommentSaveByobjId:objId
                                                     objType:objType
                                              commentContent:self.commentContent
                                                     creator:kAccountNickName
                                                  byReviewId:childModel.comment.id
                                                byReviewNick:childModel.user.nickName
                                              byReviewUserId:childModel.user.userId
                                             objPicUrlForMsg:nil
                                              objTitleForMsg:childModel.comment.content
                                                 parentObjId:objId
                                               parentObjType:[objType integerValue]
                                               operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                             sourceCommentId:model.comment.id
                                                    isParent:@"2"
                                                    Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                StrongSelf;
                if (!strongSelf) {
                    [subscriber sendError:nil];
                    return;
                }
                if (!isSuccessed) { //
                    [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                }
                [subscriber sendCompleted];
            }];
        }
        
        return nil;
    }];
    return signal;
}


#pragma mark - custom delegate

#pragma mark - system delegate

#pragma mark - event response
- (RACSignal *)praiseButtonActionWithObjId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        //1：转发PGC、2：求助、3：集市、5：话题+
        WeakSelf;
        switch (operationType) {
            case SEGNeighbourhoodOperationType_FowardPGC:
            {
                // 防止重复点赞
                if (self.isLiking) {
                    [subscriber sendError:nil];
                    return nil;
                }
                self.isLiking = YES;
                SEGSharedFowardModel* model = self.sharedNewManager.fowardInfoModel;
                if ([model.isPraise isEqualToString:@"1"]) {
                    //这里取消点赞行为方法
                    [self.socialManager requestCancelPraiseByobjId:objId
                                                           objType:@"2"
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (isSuccessed) {
                            model.isPraise = @"0";
                            model.praiseCount = [NSString stringWithFormat:@"%d",[model.praiseCount intValue] - 1];
                            [subscriber sendCompleted];
                        } else {
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                        }
                    }];
                } else {
                    //这里执行点赞行为方法
                    [self.socialManager requestPraiseAttentByObjId:objId
                                                           ObjType:@"2"
                                                   objPicUrlForMsg:model.sharePicture
                                                    objTitleForMsg:model.shareContent
                                                    byReviewUserId:self.userModel.userId
                                                       parentObjId:objId
                                                     parentObjType:[NSString stringWithFormat:@"%ld",(unsigned long)SEGUserType_ACTIVITY]
                                                     operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                                          isParent:nil
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (isSuccessed) {
                            model.isPraise = @"1";
                            model.praiseCount = [NSString stringWithFormat:@"%d",[model.praiseCount intValue] + 1];
                            [subscriber sendCompleted];
                        } else {
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                        }
                    }];
                }
                break;
            }
            case SEGNeighbourhoodOperationType_Help:
            case SEGNeighbourhoodOperationType_Topic:
            {
                // 防止重复点赞
                if (self.isLiking) {
                    [subscriber sendError:nil];
                    return nil;
                }
                self.isLiking = YES;
                SEGFindQuizListByQuizTypeModel* model = self.helpManager.dataSourceQuizDetail;
                if ([[model.isParise stringValue]isEqualToString:@"1"]) {
                    //这里取消点赞行为方法
                    [self.socialManager requestCancelPraiseByobjId:objId
                                                           objType:@"2"
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (isSuccessed) {
                            model.isParise = @(0);
                            model.praiseTotal = @([model.praiseTotal intValue] - 1);
                            [subscriber sendCompleted];
                        } else {
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:100 userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                        }
                    }];
                }else{
                    //这里执行点赞行为方法
                    [self.socialManager requestPraiseAttentByObjId:objId
                                                           ObjType:@"2"
                                                   objPicUrlForMsg:model.quizPic
                                                    objTitleForMsg:model.quizContent1
                                                    byReviewUserId:model.userId
                                                       parentObjId:objId
                                                     parentObjType:@"2"
                                                     operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                                          isParent:@"1"
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (!isSuccessed) { // 失败
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                            return;
                        }
                        model.isParise = @(1);
                        model.praiseTotal = @([model.praiseTotal intValue] + 1);
                        [subscriber sendCompleted];
                    }];
                }
                break;
            }
            case SEGNeighbourhoodOperationType_Market:
            {
                // 防止重复点赞
                if (self.isLiking) {
                    [subscriber sendError:nil];
                    return nil;
                }
                self.isLiking = YES;
                SEGQueryGoodsIdelModel* model = self.sHManager.dataSourceGoodsIdel;
                if ([[self.sHManager.dataSourceGoodsIdel.isLike stringValue]isEqualToString:@"1"]) {
                    // 取消点赞
                    [self.socialManager requestCancelPraiseByobjId:objId
                                                           objType:objType
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (isSuccessed) {
                            model.isLike = @(0);
                            model.attenCount = @([model.attenCount intValue] - 1);
                            [subscriber sendCompleted];
                        } else {
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                        }
                    }];
                } else {
                    // 执行点赞
                    [self.socialManager requestPraiseAttentByObjId:objId
                                                           ObjType:objType
                                                   objPicUrlForMsg:model.img1
                                                    objTitleForMsg:model.title
                                                    byReviewUserId:model.userId
                                                       parentObjId:model.goodsId
                                                     parentObjType:objType
                                                     operationType:[NSString stringWithFormat:@"%ld",(unsigned long)operationType]
                                                          isParent:@"1"
                                                          Finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                        StrongSelf;
                        if (!strongSelf) return;
                        strongSelf.isLiking = NO;
                        if (!isSuccessed) { // 失败
                            [subscriber sendError:[NSError errorWithDomain:NSURLErrorDomain code:codeType.integerValue userInfo:@{NSLocalizedDescriptionKey:errorMessage}]];
                            return;
                        }
                        model.isLike = @(1);
                        model.attenCount = @([model.attenCount intValue] + 1);
                        [subscriber sendCompleted];
                    }];
                }
                break;
            }
            default:
                break;
        }
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)sellOutAction {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        
        //已出手
        [self.sHManager requestUpdateStatusBygoodsId:ValueToString(self.sHManager.dataSourceGoodsIdel.goodsId)
                                             objType:[self.sHManager.dataSourceGoodsIdel convertToObjType]
                                              status:[NSString stringWithFormat:@"%lu",(unsigned long)SEGEnumIdleStatus_SaleOut]
                                            Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
            [subscriber sendNext:errorMessage];
            if (isSuccessed) {
                [subscriber sendCompleted];
            }
        }];
        
        return nil;
    }];
    return signal;
}

- (RACSignal *)deleteActionWithObjId:(NSString *)objId objType:(NSString *)objType operationType:(SEGNeighbourhoodOperationType)operationType {
    @weakify(self);
    RACSignal *signal = [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
        @strongify(self);
        if (operationType == SEGNeighbourhoodOperationType_Market) {//老接口
            [self.sHManager requestUpdateStatusBygoodsId:ValueToString(self.sHManager.dataSourceGoodsIdel.goodsId)
                                                 objType:[self.sHManager.dataSourceGoodsIdel convertToObjType]
                                                  status:[NSString stringWithFormat:@"%lu",(unsigned long)SEGEnumIdleStatus_Remove]
                                                Finished:^(BOOL isSuccessed, NSString* codeType, NSString* errorMessage) {
                [subscriber sendNext:errorMessage];
                if (isSuccessed) {
                    [subscriber sendCompleted];
                }
            }];
        } else {
            [self.sharedNewManager requestDeleteJoinHistoryWithObjId:objId
                                                             objType:objType
                                                            finished:^(BOOL isSuccessed, NSString *codeType, NSString *errorMessage) {
                [subscriber sendNext:errorMessage];
                if (isSuccessed) {
                    [subscriber sendCompleted];
                }
            }];
        }
        
        
        return nil;
    }];
    return signal;
}
#pragma mark - private methods

#pragma mark - setter and getter
- (SEGSharedNewManager *)sharedNewManager {
    if (!_sharedNewManager) _sharedNewManager = [[SEGSharedNewManager alloc] init];
    return _sharedNewManager;
}
- (SEGHelpManager*)helpManager {
    if (!_helpManager) _helpManager = [[SEGHelpManager alloc] init];
    return _helpManager;
}
- (SEGSHManager*)sHManager {
    if (!_sHManager) _sHManager = [[SEGSHManager alloc] init];
    return _sHManager;
}
- (SEGCommunitySocialManager*)socialManager {
    if (!_socialManager) _socialManager = [[SEGCommunitySocialManager alloc] init];
    return _socialManager;
}





@end
